package com.qinsoft.frame.listener;

import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.qinsoft.frame.taobao.task.ThreadPool;
import com.qinsoft.frame.taobao.task.TopTask;

public class TaobaoListener implements ServletContextListener{

    private ThreadPool pool = new ThreadPool();
    private TopTask topTask = new TopTask(pool);
    private Timer timer = new Timer();

	@Override
	public void contextDestroyed(ServletContextEvent event) 
	{
	    topTask.stop();
	}

	@Override
	public void contextInitialized(ServletContextEvent event) 
	{
	    pool.init();
	    timer.schedule(topTask, 10000);
	}
}
